Executed: Mon Mar 27 11:40:02 2017

Duration: 194 seconds.

Analysis of 5 smFRET samples

In this notebook we perform background analysis for multi-spot measurements.

Load FRETBursts software


In [1]:
from fretbursts import *


 - Optimized (cython) burst search loaded.
 - Optimized (cython) photon counting loaded.
--------------------------------------------------------------
 You are running FRETBursts (version 0.5.9).

 If you use this software please cite the following paper:

   FRETBursts: An Open Source Toolkit for Analysis of Freely-Diffusing Single-Molecule FRET
   Ingargiola et al. (2016). http://dx.doi.org/10.1371/journal.pone.0160716 

--------------------------------------------------------------

In [2]:
import os
from IPython.display import display
%matplotlib inline

In [3]:
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
from IPython.display import display
from IPython.utils.traitlets import link


/Users/anto/miniconda3/envs/multispot_paper/lib/python3.5/site-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)
/Users/anto/miniconda3/envs/multispot_paper/lib/python3.5/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.
  warn("IPython.utils.traitlets has moved to a top-level traitlets package.")

In [4]:
import lmfit
print('lmfit version:', lmfit.__version__)


lmfit version: 0.9.5

8-spot paper plot style


In [5]:
PLOT_DIR = './figure/'

In [6]:
import seaborn as sns
#%run -i styles/style.py
#np.set_printoptions(formatter={'float': lambda x: '%6.2f'%x})
import matplotlib as mpl

# brewer2mpl.get_map args: set name  set type  number of colors
#bmap = brewer2mpl.get_map('Set1', 'qualitative', 9)
bmap = sns.color_palette("Set1", 9)
colors = np.array(bmap)[(1,0,2,3,4,8,6,7), :]

In [7]:
if mpl.__version__.startswith('1.4'):
    mpl.rcParams['axes.color_cycle'] = list(colors)    
else:
    # Version 1.5 or later
    from cycler import cycler
    mpl.rcParams['axes.prop_cycle'] = cycler('color', colors)

In [8]:
colors_labels = ['blue', 'red', 'green', 'violet', 'orange', 'gray', 'brown', 'pink', ]
for c, cl in zip(colors, colors_labels):
    locals()[cl] = tuple(c) # assign variables with color names
sns.palplot(colors)


Data files

Data folder:


In [9]:
data_dir = './data/multispot/'

Check that the folder exists:


In [10]:
data_dir = os.path.abspath(data_dir) + '/'
assert os.path.exists(data_dir), "Path '%s' does not exist." % data_dir

List of data files in data_dir:


In [11]:
from glob import glob
file_list = sorted(glob(data_dir + '*.hdf5'))

In [12]:
labels = ['7d', '12d', '17d', '22d', '27d', 'DO']
files_dict = {lab: fname for lab, fname in zip(sorted(labels), file_list)}
files_dict


Out[12]:
{'12d': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/12d_New_30p_320mW_steer_3.hdf5',
 '17d': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/17d_100p_320mW_steer_1.hdf5',
 '22d': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/22d_30p_320mW_steer_1.hdf5',
 '27d': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/27d_50p_320mW_steer_1.hdf5',
 '7d': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/7d_New_150p_320mW_steer_3.hdf5',
 'DO': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/DO12_No2_50p_320mW_steer_1.hdf5'}

Parameters

Analysis parameters:


In [13]:
## Background fit parameters
bg_kwargs_auto = dict(fun=bg.exp_fit,
                 time_s = 30,
                 tail_min_us = 'auto',
                 F_bg=1.7,
                 )

Processing and plot options:


In [14]:
plt.rc('savefig', dpi=75)  # Changes the figure size in the notebook
savefig_kwargs =  dict(dpi=200, bbox_inches='tight')  # default save-figure options

5-samples processing

7bp sample


In [15]:
data_id = '7d'
d7 = loader.photon_hdf5(files_dict[data_id])
d7.calc_bg(**bg_kwargs_auto)


 - Calculating BG rates ... [DONE]

In [16]:
dplot(d7, timetrace_bg);
for period in range(d7.nperiods):
    dplot(d7, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);


12bp sample


In [17]:
data_id = '12d'
d12 = loader.photon_hdf5(files_dict[data_id])
d12.calc_bg_cache(**bg_kwargs_auto)


 * No cached BG rates, recomputing:
 - Calculating BG rates ... [DONE]

In [18]:
dplot(d12, timetrace_bg);



In [19]:
for period in range(d12.nperiods):
    dplot(d12, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);


17bp sample


In [20]:
data_id = '17d'
d17 = loader.photon_hdf5(files_dict[data_id])
d17.calc_bg_cache(**bg_kwargs_auto)


 * No cached BG rates, recomputing:
 - Calculating BG rates ... [DONE]

In [21]:
dplot(d17, timetrace_bg);



In [22]:
for period in range(d17.nperiods):
    dplot(d17, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);


22bp sample


In [23]:
data_id = '22d'
d22 = loader.photon_hdf5(files_dict[data_id])
d22.calc_bg_cache(**bg_kwargs_auto)


 * No cached BG rates, recomputing:
 - Calculating BG rates ... [DONE]

In [24]:
dplot(d22, timetrace_bg);



In [25]:
for period in range(d22.nperiods):
    dplot(d22, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);


27bp sample


In [26]:
data_id = '27d'
d27 = loader.photon_hdf5(files_dict[data_id])
d27.calc_bg_cache(**bg_kwargs_auto)


 * No cached BG rates, recomputing:
 - Calculating BG rates ... [DONE]

In [27]:
dplot(d27, timetrace_bg);



In [28]:
for period in range(d27.nperiods):
    dplot(d27, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);


D-only sample


In [29]:
data_id = 'DO'
do = loader.photon_hdf5(files_dict[data_id])
do.calc_bg_cache(**bg_kwargs_auto)


 * No cached BG rates, recomputing:
 - Calculating BG rates ... [DONE]

In [30]:
dplot(do, timetrace_bg);



In [31]:
for period in range(do.nperiods):
    dplot(do, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);